无法将类型"Response result"隐式转换为"DataTable"[

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:55:35
一个webservice的项目:
在"生成网站"的时候,提示出错
错误 1 无法将类型“Sup1GetProduct.GetProductResponseGetProductResult”隐式转换为“System.Data.DataTable”

using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
public class ServiceManager
{
//调用Sup1GetProduct,将商品信息存放到Product1表中
public static void Sup1GetProduct()
{
Sup1GetProduct.Sup1GetProduct myservice = new Sup1GetProduct.Sup1GetProduct();
DataTable dt= myservice.GetProduct();//!!!!!提示myservice处出错
for (int i = 0; i < dt.Rows.Count; i++)
{
string ProId = dt.Rows[i]["ProId"].ToString().Trim();
string ProName = dt.Rows[i]["ProName"].ToString(

建议你public DataSet GetProduct()
因为web services在客户端调用时候需要反序列化..我怀疑DataTable不支持序列换,所以没法传送.
DS是可以的.
纯属猜测

那你就尝试显式转换下 喽~
DataTable dt=(DataTable)myservice.GetProduct();

那你重新引用下试试看